package com.meida.module.system.provider.controller;

import com.meida.common.mybatis.model.*;
import com.meida.common.mybatis.query.CriteriaUpdate;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.system.client.entity.SysCompany;
import com.meida.module.system.provider.service.SysCompanyService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 企业管理接口
 *
 * @author zyf
 */
@Api(tags = "基础服务-System")
@RestController
@RequestMapping("/company/")
public class SysCompanyController extends BaseController<SysCompanyService, SysCompany> {

    @ApiOperation(value = "企业-分页列表", notes = "企业分页列表 ")
    @GetMapping(value = "pageList")
    public ResultBody pageList(@ModelAttribute(value = "pageModel") PageModel pageModel) {
        return bizService.pageList(pageModel);
    }

    @ApiOperation(value = "企业-分页列表", notes = "企业分页列表 ")
    @GetMapping(value = "page")
    public ResultBody page(@ModelAttribute(value = "pageModel") PageModel pageModel) {
        return bizService.pageList(pageModel);
    }


    /**
     * 查询企业
     */
    @ApiOperation(value = "企业-详细信息", notes = "查询企业详细信息")
    @GetMapping(value = "get")
    public ResultBody get(@ModelAttribute(value = "model") GetModel model) {
        return bizService.get(model);
    }

    /**
     * 企业详情
     */
    @ApiOperation(value = "企业-详细信息", notes = "查询企业详细信息")
    @GetMapping(value = "common/get")
    public ResultBody commonDetails(@ModelAttribute(value = "model") GetModel model) {
        return bizService.get(model);
    }

    /**
     * 企业详情
     */
    @ApiOperation(value = "企业-详细信息", notes = "查询企业详细信息")
    @GetMapping(value = "details")
    public ResultBody details(@ModelAttribute(value = "model") GetModel model) {
        return bizService.get(model);
    }



    /**
     * 更新企业
     */
    @ApiOperation(value = "企业-更新", notes = "只更新非空字段")
    @PostMapping(value = "edit")
    public ResultBody edit(@ModelAttribute(value = "model") UpdateModel model) {
        return bizService.edit(model);
    }


    @ApiOperation(value = "企业-删除", notes = "企业删除")
    @PostMapping(value = "delete")
    public ResultBody delete(@ModelAttribute(value = "deleteModel") DeleteModel deleteModel) {
        return bizService.delete(deleteModel);
    }


    /**
     * 企业申请认证
     */
    @ApiOperation(value = "企业-申请认证", notes = "企业认证")
    @PostMapping(value = "authentication")
    public ResultBody identification(@ModelAttribute(value = "model") UpdateModel model) {
        CriteriaUpdate cu = new CriteriaUpdate(model, SysCompany.class);
        return bizService.identification(cu);
    }

    @ApiOperation(value = "企业认证审核", notes = "企业认证审核")
    @PostMapping(value = "setAuditState")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", required = true, value = "主键", paramType = "form"),
            @ApiImplicitParam(name = "auditState", required = true, value = "发布状态", paramType = "form"),
            @ApiImplicitParam(name = "auditContent", required = true, value = "发布状态", paramType = "form")
    })
    public ResultBody setAuditState(@RequestParam(required = false) Map params) {
        return bizService.setAuditState(params);
    }

    @ApiOperation(value = "重置认证审核", notes = "重置企业认证")
    @PostMapping(value = "resetAuditState")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", required = true, value = "主键", paramType = "form")
    })
    public ResultBody resetAuditState(@RequestParam(value = "companyId") Long companyId) {
        return bizService.resetAuditState(companyId);
    }

    @ApiOperation(value = "设置推荐状态", notes = "设置推荐状态")
    @PostMapping(value = "setRecommend")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", required = true, value = "主键", paramType = "form"),
            @ApiImplicitParam(name = "recommend", required = true, value = "推荐状态", paramType = "query")
    })
    public ResultBody setSendStatus(@RequestParam(value = "ids") Long[] ids, @RequestParam(value = "recommend") Integer recommend) {
        return bizService.setRecommend(ids, recommend);
    }

    @ApiOperation(value = "更新电话查看量", notes = "更新电话查看量")
    @PostMapping(value = "updateLookCount")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", required = true, value = "主键", paramType = "form")
    })
    public ResultBody updateLookCount(@RequestParam(value = "companyId") Long companyId) {
        return bizService.updateLookCount(companyId, 1);
    }

}
